using System;
using System.Collections.Generic;
using System.Text;

namespace FeedFly
{
    /// <summary>
    /// Base feed class used as argument for Feed class constructor
    /// </summary>
    public class FeedBase: FeedInterface
    {
        protected int id;
        protected int folderId;
        protected string title;
        protected string description;
        protected DateTime downloadedDate;
        protected string link;
        protected string address;
        protected FeedFormat format;
        protected short itemLimit;
        protected bool downloadCancelled;
        protected bool downloadAborted;
        protected bool persisted;
        protected bool isNew;
        protected bool hasAddresses;
        protected bool hasGuids;

        public bool IsNew
        {
            get { return this.isNew; }
            set { this.isNew = value; }
        }

        public bool Persisted
        {
            get { return this.persisted; }
            set { this.persisted = value; }
        }

        public bool DownloadCancelled
        {
            get { return this.downloadCancelled; }
            set { this.downloadCancelled = value; }
        }

        public bool DownloadAborted
        {
            get { return this.downloadAborted; }
            set { this.downloadAborted = value; }
        }

        public int Id
        {
            get { return this.id; }
            set { this.id = value; }
        }

        public int FolderId
        {
            get { return this.folderId; }
            set { this.folderId = value; }
        }

        public string Address
        {
            get { return this.address; }
            set { this.address = value; }
        }

        public string Link
        {
            get { return this.link; }
            set { this.link = value; }
        }

        public short ItemLimit
        {
            get { return this.itemLimit; }
            set { this.itemLimit = value; }
        }

        public FeedFormat Format
        {
            get { return this.format; }
            set { this.format = value; }
        }

        public string Title
        {
            get { return this.title; }
            set { this.title = value; }
        }

        public string Description
        {
            get { return this.description; }
            set { this.description = value; }
        }

        public DateTime DownloadedDate
        {
            get { return this.downloadedDate; }
            set { this.downloadedDate = value; }
        }

        /// <summary>
        /// Constructor
        /// </summary>
        public FeedBase(FeedInterface feed)
        {
            this.id = feed.Id;
            this.folderId = feed.FolderId;
            this.title = feed.Title;
            this.address = feed.Address;
            this.link = feed.Link;
            this.downloadedDate = feed.DownloadedDate;
            this.itemLimit = feed.ItemLimit;
            this.format = feed.Format;
        }

        public FeedBase()
        { 
        }

        public override bool Equals(object obj)
        {
            FeedBase f = (FeedBase)obj;
            return this.address.Equals(f.Address,StringComparison.CurrentCultureIgnoreCase);
        }
    }
}
